﻿
#ifndef _BASETOOLBARVIEW_H_
#define _BASETOOLBARVIEW_H_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXEXT_H__
#include <afxext.h>
#endif


//forward definition
//class CBaseToolbarView;

//class CFMToolBarViewIdleCallBack : public CFMIdleCallBack
//{
//public:
//	CFMToolBarViewIdleCallBack():
//	m_pFMToolBarView(NULL)
//	{
//	}
//public:
//	virtual void OnIdle(LONG lCount);
//	void SetToolBarView(CBaseToolbarView *pFMToolBarView) { m_pFMToolBarView = pFMToolBarView; }
//
//protected:
//	CBaseToolbarView *m_pFMToolBarView;
//};

class CBaseToolbarView : public CFormView
{
protected:
	CBaseToolbarView();           // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(CBaseToolbarView)

// CFMIdleCallBack interface

// Form Data
public:
	//{{AFX_DATA(CBaseToolbarView)
	enum { IDD = IDD_DIALOG_TOOLBAR_VIEW };
	CFMNavigationCtrl	m_editKey;
	CString	m_szKey;
	CStatic	m_ctrlTB1Holder;
	//}}AFX_DATA

// Attributes
private:
	CFlatToolBar  m_wndToolBar;
	BOOL m_bEditHidden;// TRUE if we only want the toolbar without the FMEDIT
	CView* m_aViewPreviousFocus;// stored during OnSetFocus
	BOOL m_bViewDestroyed;

// Operations
private:
	void ShowEdit();
	BOOL IsFocusInFmedit();
	int CanSendWebURLEmail(int nMenuID);
	int CanSaveGridLayout(int nMenuID);
	void WriteRecordForCmd(UINT nRecordID, DWORD nStartTickCount, CTime oStartTime);
	int  GetBTCountForCalibrateDDA(int nIDToolbar);
public:
	static bool IsTemplateDefinitionInvisible(int nMenuID);
	void SetData();
	void InitComboBox();
	void SetValScreen(PTECR val_ecr);
	inline void SetParaImp(PTPARAIMP pParaImp) { m_pParaImp = pParaImp;}
	void SetInitFocus();
	void CreateToolbar();
	void ShowToolbar(int nToolbarType);
	BOOL IsCommandInToolbar(UINT nID);
	BOOL IsCommandEnable(UINT nID);
	void AdjustSelectionScreen();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CBaseToolbarView)
	public:
	virtual void OnInitialUpdate();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	virtual ~CBaseToolbarView();
	virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
	//{{AFX_MSG(CBaseToolbarView)
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnDestroy();
	//}}AFX_MSG
	afx_msg LRESULT OnUpdateScreen(WPARAM val_ecr, LPARAM lParam);
	afx_msg LRESULT OnMsgLetFocusInEdit(WPARAM wParam,LPARAM lParam);
	afx_msg BOOL OnTextForTooltip( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
	afx_msg LRESULT OnMessageUpdateCmdUI(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnMessageAlwaysDisableNavigation(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnMessageAfterInitialUpdate(WPARAM wParam, LPARAM lParam);
	afx_msg void OnSelchangeComboDefaultSel();
	afx_msg LRESULT OnUpdateSelEdit(WPARAM val_ecr, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
private:
	bool m_bNavigationAlwaysDisable;
	PTECR val_screen;
	PTPARAIMP m_pParaImp;
public:
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
protected:
	virtual void OnDraw(CDC* /*pDC*/);
	void ModifyToolBarViewForCompoundKeys();
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
	afx_msg void OnEditGetFocus();
	afx_msg void OnEditLostFocus();
	afx_msg void OnNavigationFinish();
	DECLARE_EVENTSINK_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif //_BASETOOLBARVIEW_H_
//  ------------------------------------------------------------
